package com.prj.ufdm.webflux.lambda;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;

public class ConsumeTest {

	
	public static void main(String[] args) {
		
		List<Person> lisiList = new ArrayList<>();
		
		Consumer<Person> consumer  = p -> {
		    if (p.getName().equals("lisi")){
		        lisiList.add(p);
		    }
		};
		
		Stream.of(
		        new Person(21,"zhangsan"),
		        new Person(22,"lisi"),
		        new Person(23,"wangwu"),
		        new Person(24,"wangwu"),
		        new Person(23,"lisi"),
		        new Person(26,"lisi"),
		        new Person(26,"zhangsan")
		).forEach(consumer);

		System.out.println(lisiList);
	}
}

class Person {
	
    private Integer age;
    private String name;
    
    Person(Integer age,String name){
    	this.age = age;
    	this.name = name;
    }
	public Integer getAge() {
		return age;
	}
	public void setAge(Integer age) {
		this.age = age;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Override
	public String toString() {
		return "Person [age=" + age + ", name=" + name + "]";
	}
    
    
}